<template>
  <el-dialog :visible.sync="isDialog"
    width="600px"
    title="任务增加">
    <el-form :model="form"
      :rules="rules"
      ref="form"
      label-position="left"
      label-width="100px">
      <el-form-item label="姓名">

      </el-form-item>
      <el-form-item label="职务">

      </el-form-item>
      <el-form-item label="选择日期"
        prop="date">
        <el-date-picker v-model="form.date"
          type="date"
          placeholder="选择日期"
          value-format="yyyy-MM-dd">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="当前任务"></el-form-item>
      <el-form-item label="增加任务"
        prop="add">
        <el-input-number v-model="form.add"
          :min="1"
          :step="1"
          :precision="0"></el-input-number>
      </el-form-item>
    </el-form>

    <span slot="footer">
      <el-button @click="isDialog = false">取 消</el-button>
      <el-button @click="submit"
        type="primary">提 交</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      isDialog: false,
      form: {},
      rules: {
        date: [{ required: true, message: '请选择日期', trigger: 'blur' }],
        add: [{ required: true, message: '请输入增加任务', trigger: 'blur' }]
      }
    }
  },

  watch: {
    isDialog(val) {
      if (val) return
      this.form = {}
      this.$refs.form.resetFields()
    }
  },

  methods: {
    submit() {
      this.$refs.form.validate(valid => {
        if (!valid) return false
      })
    }
  }
}
</script>

<style module lang="scss">
.formInput {
  width: 250px;
}
</style>
